﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Net;


namespace LOL_ClientSkin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();


        }

        List<string> soubory = new List<string>();
        string Cesta;

        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Text = "Přehled vybraných souborů";
            toolTip1.InitialDelay = 100;
            toolTip1.SetToolTip(this.button2, "Zvol pouze složku Riot Games !");

            WebRequest request = WebRequest.Create("http://florbal-info.sweb.cz/test.txt");
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());

            string odkaz = reader.ReadLine();
            string zprava = reader.ReadToEnd();

            request.Abort();
            reader.Close();
            response.Close();

           

            if (zprava.Length > 5)
            {

                if (MessageBox.Show(zprava, "Update! - tahle verze už není funkční", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    
                    Process.Start(odkaz);
                    Application.Exit();
                }
                else
                    Application.Exit();
            }
        }

        
           
          

               
            
        

            private void panel1_DragDrop(object sender, DragEventArgs e)
            {
               
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string soubor in files)
                {
                    listBox1.Items.Add(soubor);
                    Cesta = soubor.ToString();

                }
                soubory.Add(Cesta);
             
            }

            private void panel1_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = DragDropEffects.All;
            }

            private void button1_Click(object sender, EventArgs e)
            {
                if (label3.Text.Contains("Riot Games") == true)
                {
                    foreach (string cesta in soubory)
                    {
                        if (cesta.Contains("enterChampSelectPrompt.swf"))
                        {

                            if (File.Exists(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\assets\swfs\enterChampionSelect\enterChampSelectPrompt.swf")))
                            {
                                File.Delete(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\assets\swfs\enterChampionSelect\enterChampSelectPrompt.swf"));

                            }

                            File.Copy(cesta, Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\assets\swfs\enterChampionSelect\enterChampSelectPrompt.swf"));
                        }

                        if (cesta.Contains("chromeAssets.swf"))
                        {
                            if (File.Exists(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\chrome\themes\parchment\chromeAssets.swf")))
                            {
                                File.Delete(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\chrome\themes\parchment\chromeAssets.swf"));

                            }

                            File.Copy(cesta, Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\chrome\themes\parchment\chromeAssets.swf"));

                        }

                        if (cesta.Contains("buddyPanelAssets.swf"))
                        {
                            if (File.Exists(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\buddyPanelAssets.swf")))
                            {
                                File.Delete(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\buddyPanelAssets.swf"));

                            }

                            File.Copy(cesta, Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\buddyPanelAssets.swf"));

                        }

                         if (cesta.Contains("dockedChatAssets.swf"))
                        {
                            if (File.Exists(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\dockedChatAssets.swf")))
                            {
                                File.Delete(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\dockedChatAssets.swf"));

                            }

                            File.Copy(cesta, Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\cht2\themes\parchment\dockedChatAssets.swf"));

                        }

                       if (cesta.Contains("landingPageAssets.swf"))
                        {
                            if (File.Exists(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\lp\themes\parchment\landingPageAssets.swf")))
                            {
                                File.Delete(Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\lp\themes\parchment\landingPageAssets.swf"));

                            }

                            File.Copy(cesta, Path.Combine(label3.Text, @"League of Legends\RADS\projects\lol_air_client\releases\0.0.1.100\deploy\mod\lp\themes\parchment\landingPageAssets.swf"));

                        }
                    }
                     MessageBox.Show("Změny klienta byly provedeny úspěšně.", "Hotovo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    
                }
                    
                    else
                    {
                        MessageBox.Show("Vybrali jste správnou cestu ke složce ?", "Chyba");
                    }

                   


                }
            

            private void button2_Click(object sender, EventArgs e)
            {
                DialogResult result = folderBrowserDialog1.ShowDialog();
                if(result==DialogResult.OK)
                {
                    string files = folderBrowserDialog1.SelectedPath;
                    label3.Text = files.ToString();
;                }
            }

            private void oProgramuToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Form2 ab = new Form2();
                ab.Show();
            }
    }
}
